package com.himilco.ocana.gui.operator;

import com.himilco.ocana.workflow.core.bo.OperatorBO;
import com.himilco.ocana.workflow.core.bo.sm.OperatorInterventionClient;
import com.himilco.ocana.workflow.core.dao.entities.Ticket;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author oussema TOUKEBRI
 */
@ManagedBean(name = "opc")
@SessionScoped
public class OperatorIterventionContoller {

    @EJB
    private OperatorBO operatorBO;
    private OperatorIterventionModel model = new OperatorIterventionModel();
    @EJB
    private OperatorInterventionClient oic;

    public OperatorIterventionContoller() {
    }
    
    private List<Ticket> monData= new ArrayList<Ticket>();


//    public boolean count() {
//        model.setCount(model.getCount() + 1);
//        return true;
//    }
    public List<Ticket> getMonData() {
        model.setTickets(operatorBO.findAllTickets());
        return model.getTickets();
    }


    
//    public LazyDataModel<Ticket> getTickets() {
//        model.setTickets(operatorBO.findAllTickets());
////        System.out.println("Number of tickets in Controller ff " + model.getTickets().size());
////        return model.getTickets();
//        return model.getLazyModel();
//    }

    public void sendChoice() {
        if ("DISPATCH".equals(model.getOperatorChoice())) {
            System.out.println("The operator choice is : " + model.getOperatorChoice());
        } else if ("NCPCOM".equals(model.getOperatorChoice())) {
            System.out.println("The operator choice is : " + model.getOperatorChoice());
        } else {
            System.out.println("The operator choice is : " + model.getOperatorChoice());
        }
        model.getRequestParameters();
        getOic().invokeOperatorChoiceRules(model.getOperatorChoice(),getModel().getSelectedTicket() );
    }

    
//    public LazyDataModel<Ticket> getLazyModel(){
//          
//        return model.getLazyModel(); 
//    }
    public void onRowSelect() {
        System.out.println("Row selected!!");
    }

    public OperatorInterventionClient getOic() {
        return oic;
    }

    public OperatorBO getOpBO() {
        return operatorBO;
    }

    public OperatorIterventionModel getModel() {
        return model;
    }
}
